package com.sevens.service.impl;

import java.sql.Timestamp;
import java.util.List;

import com.sevens.dao.NewsDao;
import com.sevens.service.NewsService;
import com.sevens.vo.News;
import com.sevens.vo.NewsAccessary;
import com.sevens.vo.NewsOrder;

public class NewsServiceImpl implements NewsService {
	private NewsDao newsDao;

	public NewsDao getNewsDao() {
		return newsDao;
	}

	public void setNewsDao(NewsDao newsDao) {
		this.newsDao = newsDao;
	}

	@Override
	public boolean saveNews(News news) {
		// TODO Auto-generated method stub
		Timestamp d = new Timestamp(System.currentTimeMillis()); 
		news.setReleasetime(d);
		if(newsDao.saveNews(news)!= null)
		return true;
		else
			return false;
	}
	public boolean saveNewsAccessary(NewsAccessary newsAccessary){
		if(newsDao.saveNewsAccessary(newsAccessary)!=null)
			return true;
		else
			return false;
	}
	public List<News> queryAllNews(String newscategory) {
		return this.newsDao.queryAllNews(newscategory);
	}
	public List<News> queryNews(News news) {
		return this.newsDao.queryNews(news);
	}
	public boolean deleteNews(News news) {
		boolean bool = this.newsDao.deleteNews(news);
		return bool;
	}
	public boolean deleteNewsById(int newsId){
		boolean bool = this.newsDao.deleteNewsById(newsId);
		return bool;
	}
	public boolean editNews(News news) {
		Timestamp d = new Timestamp(System.currentTimeMillis()); 
		news.setReleasetime(d);
		boolean bool = this.newsDao.editNews(news);
		return bool;
	}
	public News queryNewsById(int newsId)
	{
		News news=this.newsDao.queryNewsById(newsId);
		return news;
	}
	public List<NewsAccessary> getAccessary(int newsId){
		List<NewsAccessary> list=this.newsDao.getAccessary(newsId);
		return list;
	}
	public boolean deleteAccessary(int newsId){
		return this.newsDao.deleteAccessary(newsId);
	}
	public NewsOrder saveNewsOder(NewsOrder newsOrder){
		return this.newsDao.saveNewsOder(newsOrder);
	}
}
